package com.example.view;

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JTabbedPane;

/**
 * 主视图 - 包含用户管理和垃圾管理的Tab界面
 */
public class MainView extends JFrame {
    private JTabbedPane tabbedPane;
    private UserManagementView userManagementView;
    private RubbishManagementView rubbishManagementView;
    
    public MainView() {
        initializeUI();
    }
    
    private void initializeUI() {
        setTitle("管理系统");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLayout(new BorderLayout());
        
        // 创建Tab组件
        tabbedPane = new JTabbedPane();
        
        // 创建用户管理Tab
        userManagementView = new UserManagementView();
        tabbedPane.addTab("用户管理", userManagementView);
        
        // 创建垃圾管理Tab
        rubbishManagementView = new RubbishManagementView();
        tabbedPane.addTab("垃圾管理", rubbishManagementView);
        
        // 将Tab组件添加到主窗口
        add(tabbedPane, BorderLayout.CENTER);
        
        setSize(800, 700);
        setLocationRelativeTo(null);
    }
    
    /**
     * 显示主视图
     */
    public void display() {
        setVisible(true);
    }
    
    /**
     * 刷新用户数据
     */
    public void refreshUserData() {
        userManagementView.refresh();
    }
    
    /**
     * 获取用户管理视图
     */
    public UserManagementView getUserManagementView() {
        return userManagementView;
    }
    
    /**
     * 获取垃圾管理视图
     */
    public RubbishManagementView getRubbishManagementView() {
        return rubbishManagementView;
    }
} 